/**
 * @Description:
 * @author SunYanMing<95317356@qq.com>
 * @date 2024/12/6
 */

import type { DialogProps, FormProps, RowProps } from 'element-plus';
import { FormFieldItem, menuType } from '../../BasicModalForm/types';
import { PropType } from 'vue';

export interface BasicPropsActionType {
  type?: menuType;
  show?: boolean;
  title?: string;
  disabled?: boolean;
  isPopup?: boolean;
  isValidate?: boolean;
  showRuleMessage?: boolean;
  ruleMessage?: string;
  ruleMessageType?: 'alert' | 'message';
  closeMessage?: string;
  loading?: boolean;
  height?: string;
  width?: string;
  dialogProps?: DialogProps;
  rowProps?: RowProps;
  formProps?: FormProps;
  formFields?: FormFieldItem<any>[];
  confirmButtonText?: string;
  cancelButtonText?: string;
  submit?: () => void;
  form?: { [key: string]: any };
  [key: string]: any;
}

export const basicProps = {
  // v-model:show
  show: {
    type: Boolean,
    default: false,
  },
  // v-model:type
  type: {
    type: String as PropType<menuType>,
    default: '',
  },
  // v-model:form  默认值
  form: {
    type: Object as PropType<{ [key: string]: any }>,
    default: () => ({}),
  },
  // v-model:loading
  loading: {
    type: Boolean,
    default: false,
  },
  // v-model:title
  title: {
    type: String,
    default: '',
  },
  // 是否进行校验表单
  isValidate: {
    type: Boolean,
    default: true,
  },
  // 不需要弹框
  isPopup: {
    type: Boolean,
    default: true,
  },

  showRuleMessage: {
    type: Boolean,
    default: true,
  },
  // 校验提示
  ruleMessage: {
    type: String,
    default: null,
  },
  // 提示类型
  ruleMessageType: {
    type: String as PropType<'alert' | 'message'>,
    default: null,
  },

  closeMessage: {
    type: String,
    default: '是否放弃更改内容',
  },
  // 禁用状态
  disabled: {
    type: Boolean,
    default: null,
  },
  height: {
    type: String,
    default: '',
  },
  width: {
    type: String,
    default: '',
  },
  // ElRowProps
  rowProps: {
    type: Object as PropType<RowProps>,
    default: () => ({
      gutter: 20,
    }),
  },
  // // ElFormProps
  formProps: {
    type: Object as PropType<FormProps>,
    default: () => ({
      labelPosition: 'right',
      labelWidth: '120px',
    }),
  },
  // 字段列表
  formFields: {
    type: Object as PropType<FormFieldItem<any>[]>,
    default: () => [],
  },
  dialogProps: {
    type: Object as PropType<DialogProps>,
    default: () => ({
      alignCenter: true,
      width: '600px',
      closeOnClickModal: false,
      closeOnPressEscape: false,
      showClose: false,
    }),
  },
  confirmButtonText: {
    type: String,
    default: '确 认',
  },
  cancelButtonText: {
    type: String,
    default: '取 消',
  },
};
